package Day1;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapTest {
    public static void main(String[] args) {
        Map<String,String> map=new HashMap<>();
        map.put("猫","cat");
        map.put("鼠","mouse");
        map.put("狗","dog");
        map.put(null,"bird");
        map.put("蛇",null);

        Set<String> set=map.keySet();
        Iterator<String> iterator=set.iterator();
        System.out.println("第一种--------------");
        while (iterator.hasNext()){
            String key=iterator.next();
            String value=map.get(key);
            System.out.println(key+"="+value);
        }

        System.out.println("-------enforced for:");
        Set<Map.Entry<String,String>> entries=map.entrySet();
        for (Map.Entry<String,String> o:entries){
            System.out.println(o.getKey()+"=="+o.getValue());
        }
    }
}
